// Upgrade NOTE: commented out 'float4x4 _Object2World', a built-in variable
// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'


Shader  "Vert/VertexMovementWithAlpha" {

	Properties
	 {
 _MainTex ("Texture", 2D) = "white" {}
 _LightColour0 ("Light colour 0", Color) = (1,0.73,0.117,0)
 _LightColour1 ("Light colour 1", Color) = (0.05,0.275,0.275,0)
 _LightColour2 ("Light colour 2", Color) = (0,0,0,0)
 _LightColour3 ("Rim colour", Color) = (0,0,0,0)
 _LightMultiply ("Light Multiply", Float) = 1
 _AmbientColour1 ("Light Add", Color) = (0.5,0.5,0.5,0)
 _Magnitude ("Distortion Magnitude", Float) = 1
 _Frequency ("Distortion Frequency", Float) = 1
 _Wavelength ("Distortion Wavelength", Float) = 1
 _Wavelength2 ("Distortion Wavelength 2", Float) = 1
}

	

	SubShader
     {
  Tags { "LIGHTMODE"="ForwardBase" "QUEUE"="Transparent" "RenderType"="Transparent" }
  Blend SrcAlpha OneMinusSrcAlpha

    LOD 100
	Pass
	{
	
	

	CGPROGRAM
	#pragma vertex vert
	#pragma fragment frag
	#include "UnityCG.cginc"
    #define Fixed3(value)  fixed3(value, value,value)

	struct VertexInput {
    fixed4 vertex : POSITION;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    //fixed2 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed4 tangent : TANGENT;
    fixed3 normal : NORMAL;
    fixed4 xlv_COLOR0 : COLOR;
	//VertexInput
	};


	struct VertexOutput {
	fixed4 pos : SV_POSITION;
    UNITY_FOG_COORDS(1)
    fixed4 xlv_COLOR0 : COLOR;
	fixed2 xlv_TEXCOORD0 : TEXCOORD0;
    fixed3 xlv_TEXCOORD1 : TEXCOORD1;
    //fixed3 xlv_TEXCOORD2 : TEXCOORD2;
    //fixed3 xlv_TEXCOORD3 : TEXCOORD3;
    //fixed3 xlv_TEXCOORD4 : TEXCOORD4;
	//VertexOutput
	};

	

 
 
 
 
 
 
 // float4x4 _Object2World;
 int _forceLandscape;
 float4 _MainTex_ST;
 float _Magnitude;
 float _Frequency;
 float _Wavelength;
 float _Wavelength2;
 float4 _LightColour0;
 float4 _LightColour1;
 float4 _LightColour2;
 float4 _LightColour3;
 float4 _AmbientColour1;
 
 
 


	

 sampler2D _MainTex;
 




	VertexOutput vert (VertexInput v)
	{
	VertexOutput o;
	//o.pos = UnityObjectToClipPos (v.vertex);
	//o.xlv_TEXCOORD0 = TRANSFORM_TEX(v.xlv_TEXCOORD0, _MainTex);
	
  float4 tmpvar_1;
  tmpvar_1 = v.xlv_COLOR0;
  float3 tmpvar_2;
  tmpvar_2 = normalize(v.normal);
  float3 flatWorldNormal_3;
  float4 tmpvar_4;
  half2 tmpvar_5;
  float2 tmpvar_6;
  tmpvar_6 = ((v.xlv_TEXCOORD0 * _MainTex_ST.xy) + _MainTex_ST.zw);
  tmpvar_5 = tmpvar_6;
  float4 tmpvar_7;
  tmpvar_7 = mul(unity_ObjectToWorld , v.vertex);
  float4 cse_8;
  cse_8 = (_Frequency * _Time);
  float tmpvar_9;
  tmpvar_9 = ((sin(
    ((tmpvar_7.z + cse_8) / _Wavelength)
  ).x * sin(
    ((tmpvar_7.z + cse_8) / _Wavelength2)
  ).x) * (_Magnitude * v.xlv_COLOR0.x));
  if (bool(_forceLandscape)) {
    float4 tmpvar_10;
    tmpvar_10.xzw = fixed3(0.0, 0.0, 0.0);
    tmpvar_10.y = tmpvar_9;
    tmpvar_4 = UnityObjectToClipPos( v.vertex) + tmpvar_10;
  } else {
    float4 tmpvar_11;
    tmpvar_11.yzw = fixed3(0.0, 0.0, 0.0);
    tmpvar_11.x = tmpvar_9;
    tmpvar_4 = UnityObjectToClipPos( v.vertex) + tmpvar_11;
  };
  float2 tmpvar_12;
  tmpvar_12 = ((v.xlv_TEXCOORD0 * _MainTex_ST.xy) + _MainTex_ST.zw);
  tmpvar_5 = tmpvar_12;
  float4 tmpvar_13;
  tmpvar_13.w = 0.0;
  tmpvar_13.xyz = tmpvar_2;
  float3 tmpvar_14;
  tmpvar_14 = normalize(mul(unity_ObjectToWorld , tmpvar_13).xyz);
  flatWorldNormal_3.xy = tmpvar_14.xy;
  flatWorldNormal_3.z = 0.0;
  float tmpvar_15;
  tmpvar_15 = sqrt(dot (flatWorldNormal_3, flatWorldNormal_3));
  if ((tmpvar_15 > 0.0001)) {
    flatWorldNormal_3 = normalize(flatWorldNormal_3);
  };
  float tmpvar_16;
  tmpvar_16 = clamp (-(flatWorldNormal_3).x, -1.0, 1.0);
  float tmpvar_17;
  tmpvar_17 = ((1.5708 - (
    sign(tmpvar_16)
   * 
    (1.5708 - (sqrt((1.0 - 
      abs(tmpvar_16)
    )) * (1.5708 + (
      abs(tmpvar_16)
     * 
      (-0.214602 + (abs(tmpvar_16) * (0.0865667 + (
        abs(tmpvar_16)
       * -0.0310296))))
    ))))
  )) / 1.5708);
  float tmpvar_18;
  tmpvar_18 = clamp (-(tmpvar_14).z, -1.0, 1.0);
  float tmpvar_19;
  tmpvar_19 = (1.0 - ((1.5708 - 
    (sign(tmpvar_18) * (1.5708 - (sqrt(
      (1.0 - abs(tmpvar_18))
    ) * (1.5708 + 
      (abs(tmpvar_18) * (-0.214602 + (abs(tmpvar_18) * (0.0865667 + 
        (abs(tmpvar_18) * -0.0310296)
      ))))
    ))))
  ) / 1.5708));
  o.pos = tmpvar_4;
  o.xlv_COLOR0 = tmpvar_1;
  o.xlv_TEXCOORD0 = tmpvar_5;
  o.xlv_TEXCOORD1 = (lerp (lerp (
    lerp (_LightColour0.xyz, _LightColour3.xyz, Fixed3(fixed((flatWorldNormal_3.x >= 0.0))))
  , 
    lerp (_LightColour1.xyz, _LightColour3.xyz, Fixed3(fixed((0.0 >= flatWorldNormal_3.y))))
  , Fixed3(
    lerp (tmpvar_17, (2.0 - tmpvar_17), fixed((flatWorldNormal_3.x >= 0.0)))
  )), lerp (_LightColour2.xyz, _LightColour3.xyz, Fixed3(
    fixed((0.0 >= -(tmpvar_14.z)))
  )), Fixed3(lerp (tmpvar_19,
    -(tmpvar_19)
  , 
    fixed((0.0 >= tmpvar_19))
  ))) + _AmbientColour1.xyz);

    UNITY_TRANSFER_FOG(o,o.vertex);
   
	return o;
	}


	fixed4 frag(VertexOutput i) : SV_Target
    {
    //fixed4 tmpvar_2 = tex2D(_MainTex, i.uv);
	
  float4 tmpvar_1;
  half4 main_color_2;
  fixed4 tmpvar_3;
  tmpvar_3 = tex2D (_MainTex, i.xlv_TEXCOORD0);
	UNITY_APPLY_FOG(i.fogCoord, tmpvar_3);
  main_color_2 = tmpvar_3;
  tmpvar_1 = main_color_2;
  return tmpvar_1;

	}
	ENDCG
	}
  }
}

